package com.gejingyu.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {

    public static void main(String[] args) {
        ApplicationContext context
                = new ClassPathXmlApplicationContext("bean.xml");
        //根据id获取bean
        User user1 = (User) context.getBean("user");
        user1.run();

        //根据类型获取bean
        User user2 = context.getBean(User.class);
        user2.run();

        //根据id和类型获取bean
        User user3 = context.getBean("user", User.class);
        user3.run();
    }
}
